package link;

import array.ListNode;

public class MiddleOfTheLinkedList876 {
    public ListNode middleNode(ListNode head) {
        ListNode idle = new ListNode();
        idle.next=head;
        ListNode quick = idle;
        ListNode slow = idle;
        while (quick!=null&&quick.next!=null){
            quick=quick.next.next;
            slow = slow.next;
        }
        if(quick!=null){
            return slow.next;
        }else {
            return slow;
        }
    }
}
